<?php if (!defined('BASEPATH')) exit('No direct script access allowed');

class Gps_log_list extends CI_Model {

	var $source_name = "gps_log_source";
	var $files_name = "gps_log_files";

    function __construct() {
        parent::__construct();
    }
	
	function get_list($uid, $sid = 0){

		if (is_nan($sid) &&  $sid > 0) $where_sid = "and (`a`.`sid` = ".$sid.")";
		else $where_sid = "";
		
		$query = $this->db->query("select
						`b`.`gen_time` AS `src_gen_time`,
						`b`.`upload_time` AS `upload_time`,
						`b`.`description` AS `source_desc`,
						`b`.`filename` AS `source_file`,
						`a`.*
					  from
						(`".$this->files_name."` `a` join `".$this->source_name."` `b`)
					  where
						((`a`.`uid` = `b`.`uid`)
						and (`a`.`sid` = `b`.`sid`)
						".$where_sid."
						and (`a`.`uid` = ".$uid."))
					 order by
						`b`.`gen_time` DESC ;");
		//$this->db->where("uid", $uid);
		//if (is_nan($sid) &&  $sid > 0) $this->db->where("sid", $sid);
		//$this->db->order_by("src_gen_time", "desc");
		//$query = $this->db->get($this->view_name);
		if ($query->num_rows() > 0)
			return $query->result_array();
		else
		  	return false;
	}

}

?>


